package Classic;
/*
枚举集合arr所有的子集
 */
public class Demo006 {
    public static void run(){
        int[] arr={1,3,5,7};
        int[] newArr=new int[arr.length];
        subset(arr,newArr,0,0);
    }

    public static void subset(int[] arr,int [] newArr,int subsetCount,int startIndex){
        //输出子集
        if(subsetCount==0)
            System.out.println("空集");
        else {
            for(int i=0;i<subsetCount;i++){
                System.out.print(newArr[i]+" ");
            }
            System.out.println();
        }
        //递归构造集合数为index+1的子集
        int start= startIndex;
        for(int j=start;j<arr.length;j++){
            newArr[subsetCount]=arr[j];
            subset(arr,newArr,subsetCount+1,j+1);
        }
    }
}
